﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using Incendios0_1.Camera.wpfdatamanager;

namespace Incendios0_1.Camera.camera_management
{
    /// <summary>
    /// Interaction logic for Delete_camera.xaml
    /// </summary>
    public partial class Delete_camera : Window
    {
        public Delete_camera()
        {
            InitializeComponent();
        }

        private void erase()
        {
            CameraData camera = CameraManager.SearchCamera(int.Parse(textBox1.Value.ToString()));
            if (camera == null)
            {
                Microsoft.Windows.Controls.MessageBox.Show("La camara no existe", "No encontrado", MessageBoxButton.OK, MessageBoxImage.Exclamation);
            }
            else
            {
                MessageBoxResult result = Microsoft.Windows.Controls.MessageBox.Show("Realmente desea borrar la camara " + camera.HWControlAddress, "Borrar", MessageBoxButton.YesNo, MessageBoxImage.Question);
                if (result == MessageBoxResult.Yes)
                {
                    CameraManager.deleteCamera(camera);
                }
            }

        }

        private void delete_camera_Click(object sender, RoutedEventArgs e)
        {
            erase();
        }

        private void Cancel_delete_camera_Click(object sender, RoutedEventArgs e)
        {
            this.Close();
        }

        private void textBox1_KeyUp(object sender, KeyEventArgs e)
        {
            if (e.Key == Key.Enter)
                erase();
        }
    }
}